<%--                                                                       --%>
<%-- Copyright (c) 2003-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

  function doCancel(myform) {
    myform.action = '<html:rewrite page="/bp/processTaskView.do"/>';
    myform.submit();
  }

  function findField(theForm, fieldName) {
    var elements = theForm.elements;
    var numElements = elements.length;
    for (var elementIndex = 0; elementIndex < numElements; elementIndex++) {
      var elementName = elements[elementIndex].name;
      if (elementName == fieldName) {
        return elements[elementIndex];
      }
    }
    return null;
  }
  
  function doSubmit(myform) {
    for (var i = 0; i < 10; i++) {
      var fieldName = 'logs[' + i + '].comments';
      var field = findField(myform, fieldName);
      if (field != null) {
        var comments = new String(field.value);
        if (comments.length > 255) {
          alert('<bean:message key="bp.process.validation.comments" bundle="bp.messages"/>');
          field.focus();
          return;
        }
      }
      else {
        break;
      }
    }
    myform.action = '<html:rewrite page="/bp/processTaskChangesEditSave.do"/>';
    myform.submit();
  }

</script>

<html:form action="/bp/processTaskChangesEditSave.do">
<html:hidden name="processTaskChangesEditForm" property="processOid"/>
<html:hidden name="processTaskChangesEditForm" property="number"/>
<html:hidden name="processTaskChangesEditForm" property="logtime"/>
<html:hidden name="processTaskChangesEditForm" property="userAlias"/>
<html:hidden name="processTaskChangesEditForm" property="logsCount"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle"><bean:message key="bp.process.processChanges.changes" bundle="bp.messages"/></div>
      <div class="pageInstructions"><bean:message key="bp.process.processChanges.haveBeenSaved" bundle="bp.messages"/></div>
      <div class="errorMessage"><html:errors bundle="bp.messages"/></div>
      <div class="pageSubtitle">
        <span class="left"><bean:message key="bp.process.processChanges.commentsForChanges" bundle="bp.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>
      <div class="pageInstructions">
        <logic:greaterThan name="processTaskChangesEditForm" property="logsCount" value="1">
          <bean:message key="bp.process.processChanges.enterComments" bundle="bp.messages"/>
        </logic:greaterThan>
        <logic:equal name="processTaskChangesEditForm" property="logsCount" value="1">
          <bean:message key="bp.process.processChanges.enterSingleComment" bundle="bp.messages"/>
        </logic:equal>
      </div>
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="change list table" width="100%">
        <tr class="listHeader"> 
          <th id="Date" align="left">
            <bean:message key="header.date" bundle="bp.messages"/>
          </th>
          <th id="ChangeIn" align="left">
            <bean:message key="header.changeIn" bundle="bp.messages"/>
          </th>
          <th id="Comments" align="left">
            <bean:message key="header.comments" bundle="bp.messages"/>
          </th>
        </tr>
        <logic:iterate id="logs" name="processTaskChangesEditForm" property="logs" indexId="i">
          <tr class="<%=i.intValue() % 2 == 0 ? "listEven" : "listOdd" %>">
            <html:hidden name="logs" property="contentOid" indexed="true"/>
            <html:hidden name="logs" property="contentType" indexed="true"/>
            <html:hidden name="logs" property="userId" indexed="true"/>
            <html:hidden name="logs" property="action" indexed="true"/>
            <td headers="Date">
              <bean:define id="logslogtime" name="logs" property="logtime"/>
<% 
  Long logtimeLong = (Long) pageContext.getAttribute("logslogtime");
  java.util.Date logtimeDate = new java.util.Date(logtimeLong.longValue());
  pageContext.setAttribute("logtimeDate", logtimeDate, PageContext.PAGE_SCOPE);
%>
              <bean:write name="logtimeDate" formatKey="format.datetime.full" bundle="mc.messages"/>
            </td>
            <td headers="ChangeIn">
              <logic:equal name="logs" property="action" value="110">
                <bean:message key="bp.process.processChanges.changeIn.step.documentation" bundle="bp.messages"/>
              </logic:equal>
              <logic:equal name="logs" property="action" value="111">
                <bean:message key="bp.process.processChanges.changeIn.step.priority" bundle="bp.messages"/>
              </logic:equal>
              <logic:equal name="logs" property="action" value="112">
                <bean:message key="bp.process.processChanges.changeIn.step.duration" bundle="bp.messages"/>
              </logic:equal>
              <logic:equal name="logs" property="action" value="113">
                <bean:message key="bp.process.processChanges.changeIn.step.durationType" bundle="bp.messages"/>
              </logic:equal>
            </td>
            <td headers="Comments">
              <html:textarea name="logs" property="comments" indexed="true"/>
              <logic:greaterThan name="processTaskChangesEditForm" property="logsCount" value="1">
              <% if (i.intValue() == 0) { %>
                <br>
                <html:checkbox name="processTaskChangesEditForm" property="applyToAll"/>
                <bean:message key="bp.process.processChanges.applyToAll" bundle="bp.messages"/>
              <% } %>
              </logic:greaterThan>
            </td>
          </tr>
        </logic:iterate>
      </table>
      <div class="pageButtonWrap" align="right">
        <input type="button" name="cancelData" class="pageButton" 
          onClick="doCancel(this.form);" 
          value='<bean:message key="button.cancel" bundle="bp.messages"/>'>
        <input type="button" name="saveData" class="pageButton" 
          onClick="doSubmit(this.form);" 
          value='<bean:message key="button.submit" bundle="bp.messages"/>'>
      </div>
    </td>
  </tr>
</table>
</html:form>

